package br.com.felix.fwt.ui;

import java.io.PrintWriter;

import br.com.felix.fwt.svg.SVGDocument;
import br.com.felix.fwt.ui.exception.ComponentRenderException;

public class SVGLink extends BaseComponent {

	private static final long serialVersionUID = 5865254259453010722L;

	private SVGDocument svgDocument;
	
	{
		this.cssClass = "fwtsvglink";
	}
	
	public SVGLink(SVGDocument svgDocument){
		setName(getName()+".svg");
		this.svgDocument = svgDocument;
	}

	@Override
	public void write(PrintWriter out) throws ComponentRenderException {
		Form form = getExecutingForm();
		String link = form.getClass().getSimpleName()+"?actionName=SVG&svg="+getName();
		out.println("<iframe src=\""+link+"\" width=\""+svgDocument.getWidth()+"\" height=\""+svgDocument.getHeight()+"\"/>");
	}

	public SVGDocument getSVGDocument() {
		return svgDocument;
	}

}
